<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>Title</title>
<link rel="stylesheet"
	href="${ctxPath}/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${ctxPath}/static/font-awesome-4.7.0/css/font-awesome.min.css">
<style type="text/css">
ul.list-row li {
	border: 1px solid #337ab7;
	width: 180px;
	padding: 10px 15px;
	float: left;
	border-radius: 5px;
	margin: 5px;
	list-style: none;
}
ul.list-row li:hover{
	background: lightyellow;
}
ul.list-row li a, ul.list-row li a:hover, ul.list-row li a:visited, ul.list-row li a:active,
	ul.list-row li a:link {
	text-decoration: none;
}

ul.list-row li:hover {
	cursor: pointer;
}
.panel-body{
	padding:5px;
}
.panel-body ul{
	padding:5px 5px 0px 20px;
}
.panel-body ul li{
	list-style:none;
	cursor: pointer;
}
.panel-body ul.demo li{
	list-style-image: url(../static/img/action.gif);
	cursor: pointer;
}
.row-padding{
	padding:10px 10px;margin:0 5px;
}
#loading {
	display: block;
	position: fixed;
	margin: auto;
	left: 45%;
	top: 45%;
	buttom: 0;
	width: 200px;
	height: 200px;
	overflow: hidden;
	text-align: center;
	z-index: 1002
}
#bg {
	display: block;
	position: absolute;
	top: 0%;
	left: 0%;
	width: 100%;
	height: 100%;
	background-color: #f5f5f7;
	z-index: 1001;
	-moz-opacity: 0.7;
	opacity: .70;
	filter: alpha(opacity = 70);
}

.carousel img{
	cursor: pointer;
}
.panel-heading{
	background: #E0ECFF;
}
.leave_time{
	/* float:left; */
	text-align:center;
	color:#fff;
	background:green;
	padding:10px;
	border-radius:5px;
}
.leave_time_right{
	text-align:center;
	margin-top:10px;
}
.leave_time_right .label{
	cursor: pointer;
	padding:10px;
}
	.badge-danger{
		background: #a94442;
		color: #fff;
	}
</style>
</head>
<body>
	<div class="container-fluid" >
		<div class="row">
			<ul class="list-row">
				<li data-class="task_todo"><a href="javascript:;"><i
						class="fa fa-tencent-weibo fa-3x" style="color: #337ab7"></i> 待办流程 <span id="TodoTaskCount" class="badge badge-danger"></span></a></li>
				<li data-class="task_finish"><a href="javascript:;"><i
						class="fa fa-gg fa-3x" style="color: #337ab7"></i> 已办流程 <span id="finishTaskCount" class="badge"></span></a></li>
				<li data-class="processInsCc"><a href="javascript:;"><i
						class="fa fa-bell fa-3x" style="color: #337ab7"></i> 知会流程 <span id="processInsCc" class="badge">0</span></a></li>
				<li data-class="task_cc"><a href="javascript:;"><i
						class="fa fa-bullhorn fa-3x" style="color: #337ab7"></i> 抄送任务 <span id="taskCc" class="badge">0</span></a></li>
				<li data-class="todo_task"><a href="javascript:;"><i
						class="fa fa-coffee fa-3x" style="color: #337ab7"></i> 待办任务 <span id="todo_task" class="badge badge-danger">0</span></a></li>
				<li data-class="email"><a href="javascript:;"><i
						class="fa fa-envelope-open-o fa-3x" style="color: #337ab7"></i> 邮件 <span id="email" class="badge badge-danger">0</span></a></li>
				<li data-class="temp"><a href="javascript:;"><i
						class="fa fa-save fa-3x" style="color: #337ab7"></i> 我的暂存 <span id="temp_stoage_tip" class="badge">0</span></a></li>
			</ul>
		</div>
		<div class="row row-padding">
			<div class="col-md-4">
				<div class="panel panel-primary" style="border-color:#95B8E7">
				  <div class="panel-heading" style="background: #E0ECFF;color:#000;border-color:#95B8E7">最新动态</div>
				  <div class="panel-body" style="height:120px;" >
					  <ul id="dynamic_notice" class="demo">
					  </ul>
				  </div>
				  <div class="panel-footer">
				  	 <a href="javascript:;" onclick="jumpNewDynamic()"><i class="fa fa-angle-double-right"></i> 更多</a>
				  </div>
				</div>
			</div>

			<div class="col-md-4">
				<div class="panel panel-primary" style="border-color:#95B8E7">
				  <div class="panel-heading" style="background: #E0ECFF;color:#000;border-color:#95B8E7">通知公告
				   <span class="badge" style="float:right;background:#d9534f;color:#fff" id="notice_tip"></span>
				  </div>
				  <div class="panel-body" style="height:120px">
				    <ul id="notice" class="demo">
				    </ul>
				  </div>
				    <div class="panel-footer">
                        <a href="javascript:;" onclick="jumpNotice()"><i class="fa fa-angle-double-right"></i> 更多</a>
                    </div>
				</div>
				

			</div>
		</div>
	</div>


	<script type="text/javascript"
		src="${ctxPath}/static/jquery-2.1.4/jquery.min.js"></script>
	<script type="text/javascript"
		src="${ctxPath}/static/bootstrap/js/bootstrap.js"></script>
	<script type="text/javascript"
		src="${ctxPath}/static/util.js"></script>
	<script type="text/javascript">
   $(function(){
	   $('.list-row li').click(function(){
		   var data=$(this).data('class');
		   if(data=='task_todo'){
			   //待办流程
			   var title="待办流程";
			   var href='${ctxPath}/process/toDoUsertask';
			   openTab(title,href);
		   }
		   if(data=='task_finish'){
			   //已办流程
			   var title="已办流程";
			   var href='${ctxPath}/process/toTaskFinish';
			   openTab(title,href);
		   }
		   if(data=='processInsCc'){
			   //知会流程
			   var title="知会流程";
			   var href='${ctxPath}/processInsCc/index';
			   openTab(title,href);
		   }
		   if(data=='task_cc'){
			   //我的抄送
			   var title="我的抄送";
			   var href='${ctxPath}/workCc/manager';
			   openTab(title,href);
		   }
           if(data=='todo_task'){
               //我的待办
               var title="我的待办";
               var href='${ctxPath}/todo/manager';
               openTab(title,href);
           }
           if(data=='temp'){
               //我的暂存
               var title="我的暂存";
               var  href='${path}/process/tempStoageTask/tolist';
               openTab(title,href);
           }
	   });
       getDataInfo();
       tempStoageTask();
       getNewDynamic();
       getNotice();
       getNoticeTip();
       getTaskCc();
       getTodotask();
       getProcessInsCc();
       UpOrDownWork();
       // setInterval("setWorkTime()",1000);
   })
   
   // function setWorkTime(){
	//    var show_day = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
	//     var time = new Date();
	//     var year = time.getYear();
	//     if (year < 1000) {
	//         year += 1900;
	//     }
	//     var month = time.getMonth();
	//     var date = time.getDate();
	//     var day = time.getDay();
	//     var hour = time.getHours();
	//     var minutes = time.getMinutes();
	//     var second = time.getSeconds();
	//     var dn="AM";
	//     if (hour>=12) { dn="PM"; }
   //
	//     month = month + 1;
	//     month < 10 ? month = '0' + month : month;
	//     hour < 10 ? hour = '0' + hour : hour;
	//     minutes < 10 ? minutes = '0' + minutes : minutes;
	//     second < 10 ? second = '0' + second : second;
	//     var now_time = year + '年' + month + '月' + date + '日' + ' ' + show_day[day] + ' ' + hour + ':' + minutes + ':' + second + " " + dn;
	//     document.getElementById('worktime').innerHTML = now_time;
   // }
  	//上下班打卡
   function UpOrDownWork(){
	   $('#up_leave').click(function(){
		   parent.$.messager.confirm('询问', '是否确认上班打卡？', function(b) {
	            if (b) {
	            	
	            }
		   })
	   })
	   $('#down_leave').click(function(){
		   parent.$.messager.confirm('询问', '是否确认下班打卡？', function(b) {
	            if (b) {
	            	
	            }
		   })
	   })
   }
   function openTab(title,href){
       var opts = {
               title : title,
               border : false,
               closable : true,
               fit : true,
               href : href,
           };
       parent.addTab(opts);
   }


   /**
	* 获取待办、已办流程
	*/
   function getDataInfo() {
	   $.ajax({
		   url:'${staticPath}/index/getDataInfo',
		   type:'post',
		   dataType:'json',
		   success:function (result) {
			   if(!isNull(result)){
					$('#TodoTaskCount').text(result.TodoTaskCount);
					$('#finishTaskCount').text(result.finishTaskCount);
               }
           }
	   })
   }

   /**
    * 获取知会流程
    */
   function getProcessInsCc() {
       $.ajax({
           url:'${staticPath}/processInsCc/dataGrid?userIdCcs=<shiro:principal property="id"/>',
           type:'post',
		   data:{page:1,rows:10},
           dataType:'json',
           success:function (result) {
			   $('#processInsCc').html(result.total);
           }
       })
   }
   /**
    * 获取抄送任务
    */
   function getTaskCc() {
       $.ajax({
           url:'${staticPath}/workCc/dataGrid?userId=<shiro:principal property = "id"/>',
           type:'post',
		   data:{page:1,rows:10,status:0},
           dataType:'json',
           success:function (result) {
			   $('#taskCc').html(result.total);
           }
       })
   }

   /**
	* 获取待办任务，非流程
	*/
   function getTodotask(){
       $.ajax({
           url:'${staticPath}/todo/dataGrid?userId=<shiro:principal property = "id"/>',
           type:'post',
           data:{page:1,rows:10,status:0},
           dataType:'json',
           success:function (result) {
               $('#todo_task').html(result.total);
           }
       })
   }
   /**
	* 暂存任务查询
    */
   function tempStoageTask(){
	   var userid='<shiro:principal property = "id"/>';
       $.ajax({
		   url:'${ctxPath}/process/tempStoageTask/dataGrid',
		   data:{"page":1,"rows":5,"userid":userid},
		   dataType:'json',
		   type:'post',
		   success:function(result){
		           var data=result.rows;
		           if(result.total>0){
		          	 $('#temp_stoage_tip').text(result.total);
		           }
		   }
	   })
   }


   function jumpNotice(){
       var opts = {
           title : '通知公告',
           border : false,
           closable : true,
           fit : true,
           iconCls : 'fi-folder',
           href:'${path}/notice/manager?type=2'
       };
       parent.addTab(opts);
   }

   function jumpNewDynamic(){
       var opts = {
           title : '最新动态',
           border : false,
           closable : true,
           fit : true,
           iconCls : 'fi-folder',
           href:'${path}/notice/manager?type=1'
       };
       parent.addTab(opts);
   }
   
    function getNewDynamic(){
	  $.ajax({
		  url:'${ctxPath}/notice/dataGrid',
		  type:'post',
		  data:{type:1,page:1,rows:5},
		  dataType:'json',
		  success:function(data){
			   if(data.total>0){
					for(var i=0;i<data.rows.length;i++){
                        var newImg="";
                        if(data.rows[i].readed==0){
                            newImg="<img src='${ctxPath}/static/img/news.gif'>";
                        }
                        var html="<li onclick='viewNotice(\""+data.rows[i].id+"\")'>"+newImg+data.rows[i].title+"<span style=\"float:right\">["+date2Str(data.rows[i].createTime)+"]</span></li>";
                        $('#dynamic_notice').append(html);
                    }
               }
		  }
	  })
   } 
  
  /**
  *获取通知
  */
  function getNotice(){
	  $.ajax({
		  url:'${ctxPath}/notice/dataGrid',
		  dataType:'json',
		  type:'post',
		  data:{"page":1,"rows":5,"type":"2"},
		  success:function(data){
			  if(data.rows.length>0){
				  for(var i=0;i<data.rows.length;i++){
					  var newImg="";
					  if(data.rows[i].readed==0){
						  newImg="<img src='${ctxPath}/static/img/news.gif'>";
					  }
 					  var html="<li onclick='viewNotice(\""+data.rows[i].id+"\")'>"+newImg+data.rows[i].title+"<span style=\"float:right\">["+date2Str(data.rows[i].createTime)+"]</span></li>";
					  $('#notice').append(html);
				  }
			  }
		  }
	  })
  }  
  
  function viewNotice(id){
	  parent.$.modalDialog({
            title : '查看',
            width : '80%',
            height : '80%',
            href : '${path}/notice/viewPage/' + id,
        });
  }
  
  /**
  *	  获取未读通知记录数
  */
  function getNoticeTip(){
	  $.ajax({
		  url:'${ctxPath}/notice/getNoticeTip?userid=<shiro:principal property = "id"/>&type=2',
		  success:function(data){
			  if(data>0){
				 $('#notice_tip').text(data);
			  }
		  }
	  })
  }
</script>
</body>
</html>